import React from 'react';
import { permission, userlist } from '../utils/types/home';
// import {} from '../store/model/cart.tsx';
import { useSelector, useDispatch } from 'react-redux';

import { createBrowserRouter, Navigate } from 'react-router-dom';
const Home = React.lazy(() => import('../views/Home.tsx'));
const Login = React.lazy(() => import('../views/Login.tsx'));
//用户管理
const UserManagement = React.lazy(
  () => import('../components/UserManagement/UserManagement.tsx'),
);
const CommonUser = React.lazy(
  () => import('../components/UserManagement/CommonUser.tsx'),
);
const Creator = React.lazy(
  () => import('../components/UserManagement/Creator.tsx'),
);
const InstitutionalCreator = React.lazy(
  () => import('../components/UserManagement/InstitutionalCreator.tsx'),
);
const Anchor = React.lazy(
  () => import('../components/UserManagement/Anchor.tsx'),
);
const CustomerService = React.lazy(
  () => import('../components/UserManagement/CustomerService.tsx'),
);
const Administrator = React.lazy(
  () => import('../components/UserManagement/Administrator.tsx'),
);
const Actors = React.lazy(
  () => import('../components/UserManagement/Actors.tsx'),
);
//内容管理
const ContentManagement = React.lazy(
  () => import('../components/ContentManagement/ContentManagement.tsx'),
);
const LongVideo = React.lazy(
  () => import('../components/ContentManagement/LongVideo.tsx'),
);
const ShortVideo = React.lazy(
  () => import('../components/ContentManagement/ShortVideo.tsx'),
);
const LiveBroadcast = React.lazy(
  () => import('../components/ContentManagement/LiveBroadcast.tsx'),
);
const Post = React.lazy(
  () => import('../components/ContentManagement/Post.tsx'),
);
//营销管理
const MarketingManagement = React.lazy(
  () => import('../components/MarketingManagement/MarketingManagement.tsx'),
);
const Advertisement = React.lazy(
  () => import('../components/MarketingManagement/Advertisement.tsx'),
);
const AdvertisingSpace = React.lazy(
  () => import('../components/MarketingManagement/AdvertisingSpace.tsx'),
);
const Vip = React.lazy(
  () => import('../components/MarketingManagement/Vip.tsx'),
);
const Agency = React.lazy(
  () => import('../components/MarketingManagement/Agency.tsx'),
);
const FreeVideoRights = React.lazy(
  () => import('../components/MarketingManagement/FreeVideoRights.tsx'),
);
const Gift = React.lazy(
  () => import('../components/MarketingManagement/Gift.tsx'),
);
//财务管理
const FinancialManagement = React.lazy(
  () => import('../components/FinancialManagement/FinancialManagement.tsx'),
);
const MemberOrder = React.lazy(
  () => import('../components/FinancialManagement/MemberOrder.tsx'),
);
const TopUpOrder = React.lazy(
  () => import('../components/FinancialManagement/TopUpOrder.tsx'),
);
const CashOrder = React.lazy(
  () => import('../components/FinancialManagement/CashOrder.tsx'),
);
const Ustd = React.lazy(
  () => import('../components/FinancialManagement/Ustd.tsx'),
);
const WithdrawalSetUp = React.lazy(
  () => import('../components/FinancialManagement/WithdrawalSetUp.tsx'),
);
const Zhuce = React.lazy(() => import('../views/Zhuce.tsx'));
//app管理
const App = React.lazy(() => import('../components/App/App.tsx'));
const Channel = React.lazy(() => import('../components/App/Channel.tsx'));
const LongVideoClassification = React.lazy(
  () => import('../components/App/LongVideoClassification.tsx'),
);
const ShortVideoClassification = React.lazy(
  () => import('../components/App/ShortVideoClassification.tsx'),
);
const LiveStreamClassification = React.lazy(
  () => import('../components/App/LiveStreamClassification.tsx'),
);
const PostTag = React.lazy(() => import('../components/App/PostTag.tsx'));
const ReportingCenter = React.lazy(
  () => import('../components/App/ReportingCenter.tsx'),
);
const NoticeAndAnnouncement = React.lazy(
  () => import('../components/App/NoticeAndAnnouncement.tsx'),
);
//系统设置
const SystemSetting = React.lazy(
  () => import('../components/SystemSetting/SystemSetting.tsx'),
);
const SharingStyle = React.lazy(
  () => import('../components/SystemSetting/SharingStyle.tsx'),
);
const AuthoringLevel = React.lazy(
  () => import('../components/SystemSetting/AuthoringLevel.tsx'),
);
const AppExternalLink = React.lazy(
  () => import('../components/SystemSetting/AppExternalLink.tsx'),
);
const CommonExternalChain = React.lazy(
  () => import('../components/SystemSetting/CommonExternalChain.tsx'),
);
const UserAgreement = React.lazy(
  () => import('../components/SystemSetting/UserAgreement.tsx'),
);
const CustomerServiceSettings = React.lazy(
  () => import('../components/SystemSetting/CustomerServiceSettings.tsx'),
);
const CommonProblem = React.lazy(
  () => import('../components/SystemSetting/CommonProblem.tsx'),
);
//系统管理
const SystemManagement = React.lazy(
  () => import('../components/SystemManagement/SystemManagement.tsx'),
);
const SystemDepartment = React.lazy(
  () => import('../components/SystemManagement/SystemDepartment.tsx'),
);
const SystemRole = React.lazy(
  () => import('../components/SystemManagement/SystemRole.tsx'),
);
const DataBackUp = React.lazy(
  () => import('../components/SystemManagement/DataBackUp.tsx'),
);
const RegisteredUser = React.lazy(
  () => import('../components/SystemManagement/RegisteredUser.tsx'),
);

const Index_home = React.lazy(() => import('../components/Index.tsx'));

// const Islogin = (con) => {
//   let Com = con.children.type; //判断是不是一个组件
//   if (localStorage.getItem('token')) {
//     return <Com></Com>;
//   } else {
//     return <Navigate to="/login"></Navigate>;
//   }
// };

// const { userlist, permission } = useSelector((state: any) => state.login);

const router = createBrowserRouter([
  { path: '/login', element: <Login></Login> },
  { path: '/register', element: <Zhuce></Zhuce> },
  { path: '/', element: <Login></Login> },

  {
    path: '/home',
    element: <Home></Home>,
    children: [
      {
        path: '/home/index_home',
        element: <Index_home></Index_home>,
      },
      {
        path: '/home/UserManagement',
        element: <UserManagement></UserManagement>,
        children: [
          //用户管理页面
          {
            path: '/home/UserManagement/CommonUser',
            element: <CommonUser></CommonUser>,
          },
          {
            path: '/home/UserManagement/creator',
            element: <Creator></Creator>,
          },
          {
            path: '/home/UserManagement/institutionalCreator',
            element: <InstitutionalCreator></InstitutionalCreator>,
          },
          {
            path: '/home/UserManagement/anchor',
            element: <Anchor></Anchor>,
          },
          {
            path: '/home/UserManagement/customerService',
            element: <CustomerService></CustomerService>,
          },
          {
            path: '/home/UserManagement/administrator',
            element: <Administrator></Administrator>,
          },
          { path: '/home/UserManagement/actors', element: <Actors></Actors> },
        ],
      },
      {
        path: '/home/ContentManagement',
        element: <ContentManagement></ContentManagement>,
        children: [
          //内容管理
          {
            path: '/home/ContentManagement/longVideo',
            element: <LongVideo></LongVideo>,
          },
          {
            path: '/home/ContentManagement/shortVideo',
            element: <ShortVideo></ShortVideo>,
          },
          {
            path: '/home/ContentManagement/liveBroadcast',
            element: <LiveBroadcast></LiveBroadcast>,
          },
          { path: '/home/ContentManagement/post', element: <Post></Post> },
        ],
      },
      {
        path: '/home/marketingManagement',
        element: <MarketingManagement></MarketingManagement>,
        children: [
          //营销管理
          {
            path: '/home/marketingManagement/advertisement', //广告设置
            element: <Advertisement></Advertisement>,
          },
          {
            path: '/home/marketingManagement/advertisingSpace', //广告位设置
            element: <AdvertisingSpace></AdvertisingSpace>,
          },
          {
            path: '/home/marketingManagement/vip', //vip设置
            element: <Vip></Vip>,
          },
          {
            path: '/home/marketingManagement/agency', //代理设置
            element: <Agency></Agency>,
          },
          {
            path: '/home/marketingManagement/freevideorights', //免费视频权益
            element: <FreeVideoRights></FreeVideoRights>,
          },
          {
            path: '/home/marketingManagement/gift', //礼物设置
            element: <Gift></Gift>,
          },
        ],
      },
      {
        path: '/home/financialManagement',
        element: <FinancialManagement></FinancialManagement>,
        children: [
          //财务管理
          {
            path: '/home/financialManagement/memberorder', //会员订单管理
            element: <MemberOrder></MemberOrder>,
          },
          {
            path: '/home/financialManagement/topuporder', //充值订单管理
            element: <TopUpOrder></TopUpOrder>,
          },
          {
            path: '/home/financialManagement/cashorder', //礼物订单管理
            element: <CashOrder></CashOrder>,
          },
          {
            path: '/home/financialManagement/ustd', //Ustd返现设置
            element: <Ustd></Ustd>,
          },
          {
            path: '/home/financialManagement/withdrawalsetup', //提现设置
            element: <WithdrawalSetUp></WithdrawalSetUp>,
          },
        ],
      },
      {
        path: '/home/app',
        element: <App></App>,
        children: [
          //APP管理
          {
            path: '/home/app/channel', //频道管理
            element: <Channel></Channel>,
          },
          {
            path: '/home/app/longvideoclassification', //长视频分类设置
            element: <LongVideoClassification></LongVideoClassification>,
          },
          {
            path: '/home/app/shortvideoclassification', //短视频分类设置
            element: <ShortVideoClassification></ShortVideoClassification>,
          },
          {
            path: '/home/app/liveclassification', //直播分类设置
            element: <LiveStreamClassification></LiveStreamClassification>,
          },
          {
            path: '/home/app/posttag', //帖子分类设置
            element: <PostTag></PostTag>,
          },
          {
            path: '/home/app/reportingcenter', //举报中心
            element: <ReportingCenter></ReportingCenter>,
          },
          {
            path: '/home/app/noticeandannouncement', //通知公告管理
            element: <NoticeAndAnnouncement></NoticeAndAnnouncement>,
          },
        ],
      },
      {
        path: '/home/systemsetting',
        element: <SystemSetting></SystemSetting>,
        children: [
          //系统设置
          {
            path: '/home/systemsetting/SharingStyle', //分享样式设置
            element: <SharingStyle></SharingStyle>,
          },
          {
            path: '/home/systemsetting/AuthoringLevel', //创作级别设置
            element: <AuthoringLevel></AuthoringLevel>,
          },
          {
            path: '/home/systemsetting/AppExternalLink', //APP外部链接设置
            element: <AppExternalLink></AppExternalLink>,
          },
          {
            path: '/home/systemsetting/CommonExternalChain', //常用外链设置
            element: <CommonExternalChain></CommonExternalChain>,
          },
          {
            path: '/home/systemsetting/UserAgreement', //用户协议管理
            element: <UserAgreement></UserAgreement>,
          },
          {
            path: '/home/systemsetting/CustomerServiceSettings', //客服设置
            element: <CustomerServiceSettings></CustomerServiceSettings>,
          },
          {
            path: '/home/systemsetting/CommonProblem', //常见问题管理
            element: <CommonProblem></CommonProblem>,
          },
        ],
      },
      {
        path: '/home/SystemManagement',
        element: <SystemManagement></SystemManagement>,
        children: [
          //系统管理
          {
            path: '/home/SystemManagement/SystemDepartment', //系统部门管理
            element: <SystemDepartment></SystemDepartment>,
          },
          {
            path: '/home/SystemManagement/SystemRole', //系统角色管理
            element: <SystemRole></SystemRole>,
          },
          {
            path: '/home/SystemManagement/DataBackUp', //数据备份管理
            element: <DataBackUp></DataBackUp>,
          },
          {
            path: '/home/SystemManagement/RegisteredUser', //注册用户管理
            element: <RegisteredUser></RegisteredUser>,
          },
        ],
      },
    ],
  },
]);
export default router;
